from django.db import models
from main.models import *
from user.models import *
# Create your models here.

class Collect(models.Model):
    user = models.ForeignKey(verbose_name="用户", to=CustomUser, max_length=100, on_delete=models.CASCADE)
    question = models.ForeignKey(verbose_name="问答", to=Question, max_length=100, on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        unique_together = (('user', 'question'),)

    def __str__(self):
        return f'{self.user}   收藏了  {self.question}'